home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_FFILE.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
3KB
|
125 lines
*' $Header: E:/test/sysproc/doc/_ffile.prv 1.2 12 Aug 1992 16:55:56 Bill Ramos $
FUNCTION _FFile
PARAMETER pc_file
*--------------------------------------------------------------------------
* NAME
* FFILE - Determine if a file exists in the dBASE
* path.
*
* SYNOPSIS
* FFILE( pc_file )
*
* DESCRIPTION
* FFILE() searches the dBASE path for the given file
* pc_file and returns the path with a trailing "\"
* if found. If the file is not found, FFILE() will
* return a null string.
*
* FFILE() will search the current directory first,
* then process other directories in the order of the
* SET PATH list.
*
* If there is no dBASE PATH setting, FFILE() will
* look only in the current directory.
*
* The file name may have trailing blanks, but not
* leading blanks.
*
* PARAMETER
* pc_file - the file to search for.
*
* EXAMPLE
*
* SET PATH TO C:\DBASE,C:\CCBOOSTR\SAMPLES
* ? FFile( "CONFIG.DB" )
* * Would return: "C:\DBASE\"
* * if CONFIG.DB is in the C:\DBASE directory
*
* LIMITATIONS
* The file name passed to FFILE() must not include a
* path name.
*
* Since FFILE() uses the dBASE FILE() command, in
* some rare situations (when too many files have
* been opened) FFILE() may return "" even though the
* file really is in the search path. Modifying the
* "FILES=" statement in the DOS CONFIG.SYS file will
* normally correct this.
*
* VERSION
* dBASE IV 1.1
*
* SEE ALSO:
* FILE, SET("PATH")
*
*--------------------------------------------------------------------------
PRIVATE lc_curdir, lc_path, lc_return, lc_spath, ln_delim, lc_slash
IF LEFT( OS(), 3 ) = "DOS"
lc_slash = "\"
ELSE
lc_slash = "/"
ENDIF
lc_path = SET( "PATH" )
lc_curdir = SET( "DIRECTORY" )
lc_return = ""
*-- If no path, then check the current directory
IF IsBlank( lc_path )
IF FILE( pc_file )
lc_return = lc_curdir + lc_slash
ENDIF
ELSE
*-- Check the current directory first
IF FILE( lc_curdir + lc_slash + pc_file )
lc_return = lc_curdir + lc_slash
ELSE
ln_delim = MAX( AT( ",", lc_path ), AT( ";", lc_path ) )
DO WHILE ln_delim <> 0
lc_spath = LEFT( lc_path, ln_delim - 1 )
IF RIGHT( TRIM( lc_spath ), 1 ) <> lc_slash
lc_spath = TRIM( lc_spath ) + lc_slash
ENDIF
IF FILE( lc_spath + pc_file )
lc_return = lc_spath
EXIT
ENDIF
lc_path = SUBSTR( lc_path, ln_delim + 1 )
ln_delim = MAX( AT( ",", lc_path ), AT( ";", lc_path ) )
IF ln_delim = 0
lc_spath = lc_path
IF RIGHT( TRIM( lc_spath ), 1 ) <> lc_slash
lc_spath = TRIM( lc_spath ) + lc_slash
ENDIF
IF FILE( lc_spath + pc_file )
lc_return = lc_spath
EXIT
ENDIF
ENDIF
ENDDO
ENDIF
ENDIF
RETURN( UPPER( lc_return ) )
*-- EOF: FFile( pc_file )
*'-------------------------------------------------------------------------
*' $Log: E:/test/sysproc/doc/_ffile.prv $
*'-------------------------------------------------------------------------